//
//  SettingUsrViewController.m
//  muscleLife
//
//  Created by xalo on 16/4/28.
//  Copyright © 2016年 HeavenAndHell. All rights reserved.
//

#import "SettingUsrViewController.h"
#import "AboutAppViewController.h"


@interface SettingUsrViewController ()<UITableViewDelegate, UITableViewDataSource>

@property (weak, nonatomic) IBOutlet UITableView *tableView;

@end

@implementation SettingUsrViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [[self.tableView layer] setMasksToBounds:YES];
    [[self.tableView layer] setCornerRadius:10];
    self.automaticallyAdjustsScrollViewInsets = NO;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:@"CELL"];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"CELL"];
    }

    NSArray* array = @[@"缓存管理",@"音乐管理",@"训练设置",@"连接健康",@"扫一扫",@"关于",@"帮助与反馈"];
    cell.backgroundColor = [UIColor clearColor];
    cell.textLabel.text = [array objectAtIndex:indexPath.section == 0?indexPath.row:indexPath.section*2 + indexPath.row + 1];
    return cell;
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{

    return 3;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{

    if (section == 0) {
        return 3;
    }else{
        return 2;
    }
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    if (section == 0) {
        return 0;
    }
    return 30;
}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{

    UIView* view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 30)];
    view.backgroundColor = [UIColor whiteColor];
    if (section == 0) {
        return nil;
    }
    return view;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    if (indexPath.section == 2) {
        switch (indexPath.row) {
            case 0:{
                AboutAppViewController* view = [[AboutAppViewController alloc] initWithNibName:@"AboutAppViewController" bundle:nil];
                [self.navigationController pushViewController:view animated:YES];
            }break;
            case 1:{

                UIViewController* view = [[UIViewController alloc] initWithNibName:@"HelpViewController" bundle:nil];
                [self.navigationController pushViewController:view animated:YES];
            }break;
            default:
                break;
        }
    }
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
